#include <iostream>
using namespace std;

const int N = 105;
int f[N];
bool noway[N][N];

int find(int i)
{
    if (f[i] == i)
    {
        return i;
    }
    return f[i] = find(f[i]);
}

void merge(int a, int b)
{
    int fa = find(a);
    int fb = find(b);
    if (fa == fb)
    {
        return;
    }
    f[fa] = fb;
}

int main()
{
    int n, m, k;
    cin >> n >> m >> k;
    for (int i = 1; i < n; i++)
    {
        f[i] = i;
    }
    while (m--)
    {
        int a, b, i;
        cin >> a >> b >> i;
        if (i == -1)
        {
            noway[a][b] = true;
            noway[b][a] = true;
        }
        else
        {
            merge(a, b);
        }
    }
    while (k--)
    {
        int a, b;
        cin >> a >> b;
        if (find(a) == find(b))
        {
            if (noway[a][b])
            {
                cout << "OK but..." << endl;
            }
            else
            {
                cout << "No problem" << endl;
            }
        }
        else
        {
            if (noway[a][b])
            {
                cout << "No way" << endl;
            }
            else
            {
                cout << "OK" << endl;
            }
        }
    }
    return 0;
}